// 导入定义验证规则的包
const joi = require('joi')

// 定义发布文章的验证规则
const id = joi.number().integer().min(1).required()
const title = joi.string().min(1).max(30).required()
const cate_id = joi.number().integer().min(1).required()
const content = joi.string().required()
const cover_img = joi.string().required()
const state = joi.string().required()
const author_id = joi.number().integer().min(1).required()
const author_name = joi.string().required()
// const publish_tiem = joi.number().required()

// 发布文章基本信息的验证规则对象
exports.publish_article_schema = {
  // 需要对 req.body 里面的数据进行验证
  body: {
    title,
    cate_id,
    content,
    cover_img,
    state,
    author_id,
    author_name,
    // publish_tiem,
  }
}

// 根据id更新文章信息的验证规则对象
exports.update_article_schema = {
  // 需要对 req.body 里面的数据进行验证
  body: {
    id,
    title,
    cate_id,
    content,
    cover_img,
    state,
    author_name,
  }
}